<% layout('/layouts/default.html', {title: '考核任务指标表管理', libs: ['dataGrid','fileupload','validate']}){ %>
<div class="main-content">
	<div class="box box-main" id="topId">
		<div class="box-header">
			<div style="float: left">
				<div class="form-group">
					<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('返回')}</button>
				</div>
			</div>
			<#form:form id="searchForm" model="${dcSupExamSumQuotaInfo!}" action="${ctx}/quota/dcSupExamSumQuotaInfo/listKeyData?sumQuotaId=${dcSupExamQuota.versionId}&quotaGroup=1&exameOrg=${dcSupExamQuota.createOrg}" method="post" class="form-inline "
			data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize!100}" data-order-by="${parameter.orderBy}">
			<div style="float: right">
				<div class="form-group">
					<label class="control-label">${text('类别')}：</label>
					<div class="control-inline width-160">
						<#form:select path="quotaType" dictType="dc_quotaType" blankOption="true" data-placeholder="请选择" itemLabel="dictLabel" itemValue="dictValue" class="form-control width-160"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button onclick="cz();" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</div>
		</#form:form>

	</div>
	<div class="box-body" >

		<div style="float: left;">
			<div class="form-group">
				<label class="blue " >${text('关键考核指标')}</label>
			</div>
		</div>
		<div style="float: right;">

		</div>
	</div>
	<#form:form id="inputForm" model="${dcSupExamQuota}" action="${ctx}/quota/dcSupExamQuota/save" method="post" class="form-horizontal">
	<div class="box-body">

		<table id="dataGrid"></table>
	</div>
	<p style="height: 10px"></p>
	<div class="row">
	<div class="col-xs-6">
		<div class="form-group">
			<label class="control-label col-sm-4" title="">
				<span class="required hide">*</span> ${text('联系人&nbsp;&nbsp;')}：<i class="fa icon-question hide"></i></label>
			<div class="col-sm-8">
				<#form:hidden path="id" />
				<#form:input path="contactName" class="form-control"/>
			</div>
		</div>
	</div>
		<div class="col-xs-6">
			<div class="form-group">
				<label class="control-label col-sm-4" title="">
					<span class="required hide">*</span> ${text('联系电话')}：<i class="fa icon-question hide"></i></label>
				<div class="col-sm-8">
					<#form:input path="contactPhone" class="form-control"/>
					<#form:hidden path="dcSupExamQuotaInfoList" class="form-control"/>
					<#form:hidden path="createOrg" />
				</div>
			</div>
		</div>
	</div>
		<p class="h"></p>
	<div class="row">
		<div class="col-xs-12">
			<div class="form-group">
				<span class="control-label col-sm-2">
					<span class="required hide">*</span>附件上传：</span>
				<div class="col-sm-10">
					<#form:fileupload id="uploadFile" bizKey="${dcSupExamQuota.id}" bizType="dcSupExamQuota_file"
					uploadType="all" class="" readonly="true" preview="true" maxUploadNum="3"/>
				</div>
			</div>
		</div>
	</div>
</div>

</div>
</#form:form>
<% } %>
<style>
	.h{
		height: 10px;
	}
</style>
<script src="${ctxStatic}/m/js/total.js?${_version}"></script>
<script>
	$(function (){
		window.location.hash="#topId";
	})
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [

		{header:'${text("指标类别")}', name:'quotaType', width:150,
			formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('dc_quotaType')},
						val, '${text("未知")}', true);
			},
			unformat: function(val, obj, cell){
				return $('#'+obj.rowId+'_quotaType').val();
			},
			editable:true, edittype:'select', editoptions:{'class':'form-control',
				items: $.merge([{dictLabel:'&nbsp;',dictValue:''}],
						${@DictUtils.getDictListJson('dc_quotaType')}),
				itemLabel: 'dictLabel', itemValue: 'dictValue', dataInit: function(element){
					$(element).select2().on("change",function(){$(this).resetValid()});
				}
			}
		},
		{header:'${text("主键")}', name:'id', hidden:true
		},
		{header:'${text("序号")}', name:'sortNum', width:150,
			editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control'},
			unformat: function(val, obj, cell){
				return $('#'+obj.rowId+'_sortNum').val();
			}},
		{header:'${text("目标内容")}', name:'quotaContent', index:'a.quota_content', width:250, align:"left"},
		{header:'${text("单位")}', name:'quotaUnit', width:80,
			editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control'},
			unformat: function(val, obj, cell){
				return $('#'+obj.rowId+'_quotaUnit').val();
			}},
		{header:'${text("权数")}', name:'quotaWeight', width:100,
			editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control'},
			unformat: function(val, obj, cell){
				return $('#'+obj.rowId+'_quotaWeight').val();
			}
			,
			formatter: function(val, obj, row, act){
				if (val==''||typeof val=="undefined"){val=0;}
				return val.toFixed(2);
			}},
		{header:'${text("本年度目标")}', name:'currentYaerGoal', index:'a.current_yaer_goal', width:150, align:"left"},
		{header:'${text("上一年度目标任务")}', name:'lastYaerGoal', index:'a.last_yaer_goal', width:150, align:"left"},
		{header:'${text("上一年度完成情况")}', name:'lastYearComplete', index:'a.last_year_complete', width:150, align:"left"},
		{header:'${text("备注")}', name:'remarks', index:'a.remarks', width:150, align:"left", formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('dc_exam_remarks')}, val, '${text("未知")}', true);
			}},
/*		{header:'${text("上传细则")}', name:'fileuploadId', width:250,
			editable: true, edittype: "custom", editoptions: {
				custom_element: function(val, editOptions) {
					console.log(editOptions,'===',val)
					return js.template('fileuploadTpl', {
						id: 'fileupload_'+editOptions.id, title: '区域选择',
						bizKey: editOptions.rowId, bizType: 'dcSupExamQuotaInfo_file', cssClass: '', readonly: false
					});
				}
			},unformat: function(val, obj, cell){
				return $('#fileupload_'+obj.rowId+'_fileuploadId', cell).val();}
		},*/

	],
	autoGridHeight: function(){return 'auto'},
	// 加载成功后执行事件
	showRownum: false,
	showFooter: true, // 是否显示底部合计行
	ajaxSuccess: function(data){
		refreshZpCount()
	}
});

//打开新的标签
function addQuotaInfo(QuotaId) {
	js.addTabPage(null, "新增指标","${ctx}/quota/dcSupExamQuotaInfo/form?QuotaId="+QuotaId+"&quotaGroup=${dcSupExamQuota.quotaGroup}", true);
}
$("#btnSubmit").click(function(){
//示范一个公告层
	layer.open({
		type: 1
		,title: ['关键指标报送', 'font-size:18px; color:orange;'] //不显示标题栏
		,btn: ['确认', '取消']
		,btnAlign: 'c'
		,area: '300px;'
		,moveType: 1 //拖拽模式，0或者1
		,content: '<div style="padding: 50px">您确定报送XXXXXXXXXX指标吗</div>'
		,yes: function(layero){


					js.ajaxSubmitForm($('#inputForm'), function(data){
						js.showMessage(data.message);
						if(data.result == Global.TRUE){
							js.closeCurrentTabPage(function(contentWindow){
								contentWindow.page();
							});
						}
					}, "json");


		}
	});

})
function updateInfo(id) {

	let allData =JSON.stringify($('#dataGrid').dataGrid('getRowData', id));
	let dcSupExamQuotaInfo ={"dcSupExamQuotaInfo":allData}
	js.ajaxSubmit({url:"${ctx}/quota/dcSupExamQuotaInfo/saveStr",data:dcSupExamQuotaInfo,dataType: 'json',callback:function (data){
			if (data.result=="true"){
				js.showMessage(data.message);
				js.closeCurrentTabPage()
			}else {
				js.showMessage(data.message);
			}
		}})
}
function cz(){
	searchForm.reset();
	$('#dataGrid').dataGrid('reloadGrid');
}
</script>
<script id="fileuploadTpl" type="text/template">//<!--<div>
<#form:fileupload id="{{d.id}}" bizKey="{{d.bizKey}}" bizType="{{d.bizType}}" uploadType="all"
	class="{{d.cssClass}}" maxUploadNum="1"  isMini="true" preview="true" readonly="{{d.readonly}}"/>
</div>//--></script>